package control;

import java.util.Observable;
import java.util.Observer;

/**
 * Handles Notifications sent from dicepanel
 * and hands it over to the gameControl
 * 
 * @author Thomas
 *
 */

public class NotificationManager extends Observable implements Observer{

	private static NotificationManager staticInstance = null;
	
	public NotificationManager() {
		this.addObserver(GameControl.getControlInstance());
	}
	
	
	/**
	 * Singleton Pattern
	 * 
	 * @return the static instance
	 */
	public static NotificationManager getManager()
	{
		if(staticInstance == null)
			staticInstance = new NotificationManager();
		
		return staticInstance;
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		//System.out.println(((observableTest) arg0).getMessage() + " + " + arg1);
		this.setChanged();
		notifyObservers(((ObservableObject) arg0).getMessage());
	}
	
	public synchronized void setChanged() {
	    super.setChanged();
	}

}
